#include "Preloader.h"
#include <fstream>
#include <iostream>

bool Preloader::loadConfig(const std::string& configpath)
{
    std::ifstream configfile(configpath);
    if(!configfile.is_open()) 
    {
        std::cerr << "configuration cannot loaded." << std::endl;
        return false; 
    }
   
    configContent.clear();
    std::string line;
    while (std::getline(configfile, line))
        configContent += line + "\n";
    std::cout << "loading configuration finished." << std::endl;
    return true;    
}

std::string Preloader::getConfigContent() const 
{
    return configContent;
}

Preloader& Preloader::getInstance()
{
    static Preloader instance;
    return instance;
}

const Preloader* Preloader::getInstancePointer() const
{
    const Preloader* const ptr = &getInstance();
    return ptr;
}